package com.mxcyk.serviceLogic;

/**
 * 功能：获取所有根路径（磁盘分区）的空间详情
 * @author k
 *
 */
import java.io.File;

public class DriveList {
	File[] roots;//系统的所有分区
	public File[] getRoots() {
		return roots;
	}
	public DriveList(){
		roots = File.listRoots();//获取磁盘分区列表  
	}
	public static void main(String[] args) {
		DriveList dl=new DriveList();
	    File[]roots=dl.getRoots();
	    for (int i = 0; i < roots.length; i++) {
	      System.out.println(roots[i]);
	      System.out.println("Free space = " + roots[i].getFreeSpace());
	      System.out.println("Usable space = " + roots[i].getUsableSpace());
	      System.out.println("Total space = " + roots[i].getTotalSpace());
	    }
	    for (int i = 0; i < roots.length; i++) {
	    	//System.out.println("分区名："+roots[i].get);
	        System.out.println("你的电脑的磁盘分区为："+roots[i]+"   是否为可操作分区："+roots[i].canRead());
	        
	    }

	  }

}
